/*
 *
 * Copyright 2017-2018. All rights reserved.
 *
 * This copyrighted material is made available to anyone wishing to use, modify,
 * copy, or redistribute it subject to the terms and conditions of the GNU
 * Lesser General Public License, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this distribution; if not, see <http://www.gnu.org/licenses/>.
 *
 */
package com.loveprogrammer.engine.enums;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;

/**
 * 每一级所需要的经验
 *
 * @author eric
 * @version 1.0.0
 */
public enum LevelExpEnum {

    一级(1, 100),
    二级(2, 500),
    三级(3, 1300),
    四级(4, 2900),
    五级(5, 6100),
    六级(6, 12500),
    七级(7, 20000),
    八级(8, 30000),
    九级(9, 43000),
    十级(10, 60000),
    十一级(11, 78000),
    十二级(12, 100000),
    十三级(13, 130000),
    十四级(14, 170000),
    十五级(15, 220000),
    十六级(16, 300000),
    十七级(17, 400000),
    十八级(18, 510000),
    十九级(19, 630000),
    二十级(20, 760000),
    二十一级(21, 960000),
    二十二级(22, 1200000),
    二十三级(23, 1480000),
    二十四级(24, 1780000),
    二十五级(25, 2150000),
    二十六级(26, 2600000),
    二十七级(27, 3150000),
    二十八级(28, 3800000),
    二十九级(29, 4500000),
    三十级(30, 5300000),
    三十一级(31, 6200000),
    三十二级(32, 7200000),
    三十三级(33, 8300000),
    三十四级(34, 9500000),
    三十五级(35, 10800000),
    三十六级(36, 12200000),
    三十七级(37, 13700000),
    三十八级(38, 15300000),
    三十九级(39, 17000000),
    四十级(40, 19000000),
    四十一级(41, 21100000),
    四十二级(42, 23500000),
    四十三级(43, 26200000),
    四十四级(44, 29200000),
    四十五级(45, 32400000),
    四十六级(46, 36000000),
    四十七级(47, 40000000),
    四十八级(48, 44500000),
    四十九级(49, 49500000),
    五十级(50, 55500000),
    五十一级(51, 100375000);

    private int level;

    private int exp;

    LevelExpEnum(int level, int exp) {
        this.level = level;
        this.exp = exp;
    }

    public int getLevel() {
        return level;
    }

    public void setLevel(int level) {
        this.level = level;
    }

    public int getExp() {
        return exp;
    }

    public void setExp(int exp) {
        this.exp = exp;
    }

    public static LevelExpEnum getByLevel(int level){
        Optional<LevelExpEnum> optional =
                Arrays.stream(LevelExpEnum.values())
                        .filter(v -> Objects.equals(v.getLevel(), level))
                        .findFirst();

        return optional.orElse(LevelExpEnum.二十七级);
    }
}
